package com.phb.puhuibao.web.controller;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.idp.pub.service.IBaseService;
import com.idp.pub.web.controller.BaseController;
import com.phb.puhuibao.entity.ZhifubaoAccount;
import com.phb.puhuibao.entity.ZhifubaoTransfer;
 

@Controller
@RequestMapping(value = "/zhifubaoAccount")
public class ZhifubaoAccountController extends BaseController<ZhifubaoAccount, String> {
	@Resource(name = "zhifubaoAccountService")
	public void setBaseService(IBaseService<ZhifubaoAccount, String> baseService) {
		super.setBaseService(baseService);
	}
	
	@javax.annotation.Resource(name = "zhifubaoTransferService")
	private IBaseService<ZhifubaoTransfer, String> ZhifubaoTransferService;
	
 
	/**
	 * 支付宝账号列表
	 * @param muid
	 * @return
	 */
	@RequestMapping(value="zhifubaoList")
	@ResponseBody
	public Map<String, Object> zhifubaoList(@RequestParam int muid) {
		Map<String, Object> data = new HashMap<String, Object>();
		
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("muserId", muid);
 
		try {
			    List<ZhifubaoAccount> account = this.getBaseService().findList(params);
				data.put("accountList", account);
				data.put("status", 1);
				return data;
		} catch (Exception e) {
			data.put("message", "异常！");
			data.put("status", 0);
			return data;
		}
	}
	
	
	 
	/**
	 * 支付宝账号增加
	 * @param pageno
	 * @param muid
	 * @return
	 */
	@RequestMapping(value="zhifubaoAdd")
	@ResponseBody
	public Map<String, Object>zhifubaoAdd(@RequestParam int muid,@RequestParam String  zhifubao) {
		Map<String, Object> data = new HashMap<String, Object>();
		ZhifubaoAccount za = new ZhifubaoAccount();
		za.setMuserId(muid);
		za.setAliAccount(zhifubao);
		try {
			    ZhifubaoAccount  account = this.getBaseService().save(za);
				data.put("account", account);
				data.put("status", 1);
				return data;
		} catch (Exception e) {
			data.put("message", "异常！");
			data.put("status", 0);
			return data;
		}
	}
	
	/**
	 * 支付宝账号删除
	 * @param pageno
	 * @param muid
	 * @return
	 */
	@RequestMapping(value="zhifubaoDelete")
	@ResponseBody
	public Map<String, Object>zhifubaoDelete(@RequestParam int  zhifubaoId) {
		Map<String, Object> data = new HashMap<String, Object>();
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("recordId", zhifubaoId);
		 
		try {
			    int  delete = this.getBaseService().delete(params);
				data.put("message", "删除支付宝成功!");
				data.put("status", 1);
				return data;
		} catch (Exception e) {
			data.put("message", "异常！");
			data.put("status", 0);
			return data;
		}
	}
	
 
	
}
